package com.example.Laboratory.Controller;

import com.example.Laboratory.Entity.Researcher;
import com.example.Laboratory.Service.ResearcherService;
import com.example.Laboratory.Untils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@Api(value = "Researcher", description = "研究队伍-人员名单")
@RestController
@RequestMapping(value = "/Researcher")
@CrossOrigin
public class ResearcherController {

    @Autowired
    ResearcherService researcherService;

    @ApiOperation(value = "添加骨干信息", notes = "添加骨干信息")
    @RequestMapping(value = "/addResearcher", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object addResearcher (Researcher r) throws IOException {
        return ResultCode.SUCCESS.result(researcherService.addResearcher(r));
    }

    @ApiOperation(value = "删除骨干信息", notes = "添加骨干信息")
    @RequestMapping(value = "/deleteResearcher", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
    public Object deleteResearcher (@RequestParam int researcher_id) throws IOException {
        return ResultCode.SUCCESS.result(researcherService.deleteResearcher(researcher_id));
    }

    @ApiOperation(value = "查找骨干信息", notes = "查找骨干信息")
    @RequestMapping(value = "/researchResearcher", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object researchResearcher ( ) throws IOException {
        return ResultCode.SUCCESS.result(researcherService.researchResearcher());
    }

    @ApiOperation(value = "修改骨干信息", notes = "修改骨干信息")
    @RequestMapping(value = "/reviseResearcher", method = RequestMethod.POST, produces = "application/json;charset=utf-8")
    public Object reviseResearcher (Researcher r) throws IOException {
        return ResultCode.SUCCESS.result(researcherService.reviseResearcher(r));
    }
}
